//
//  UIAnimateDemo.swift
//  firstProject
//
//  Created by 张彦辉 on 2017/4/13.
//  Copyright © 2017年 张彦辉. All rights reserved.
//

import UIKit
import SnapKit

class UIAnimateDemo: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        //设置最底层背景图
        let imageView = UIImageView(frame: self.view.frame)
        let image = UIImage(named: "6")
        imageView.image = image
        self.view.addSubview(imageView)
        
        //设置毛玻璃效果
        let blurEffect = UIBlurEffect(style: .dark)
        let effectView = UIVisualEffectView(effect: blurEffect)
        effectView.frame = imageView.frame
        imageView.addSubview(effectView)
        
        //设置圆角
        let bgImageView = UIImageView()
        bgImageView.image = UIImage(named: "6")
        bgImageView.layer.masksToBounds = true
        bgImageView.layer.cornerRadius = 100
        bgImageView.layer.borderWidth = 8
        bgImageView.layer.borderColor = UIColor.black.cgColor
        effectView.addSubview(bgImageView)
        
        bgImageView.snp.makeConstraints { (maker) in
            maker.center.equalTo(effectView)
            maker.width.height.equalTo(200)
        }
        
        //设置动画效果
        let animation = CABasicAnimation(keyPath: "transform.rotation.z")
        animation.fromValue = 0
        animation.toValue = Float.pi * 2
        animation.repeatCount = MAXFLOAT
        animation.duration = 30
        
        bgImageView.layer.add(animation, forKey: nil)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
